package com.demo.result;

/**
 * 通用响应对象
 *
 * @author SPL
 * @since 2020-02-04 11:52
 */
public class AjaxResult {

    /**
     * 响应编号
     */
    private int code;
    /**
     * 响应信息
     */
    private String message;

    /**
     * 响应数据
     */
    private Object result;

    public AjaxResult() {
    }

    public AjaxResult(int code) {
        this.code = code;
    }

    public AjaxResult(int code, String msg) {
        this.code = code;
        this.message = msg;
    }


    /**
     * 失败
     */
    public static AjaxResult error(int code, String msg) {
        return new AjaxResult(code, msg);
    }

    /**
     * 失败
     */
    public static AjaxResult error(String msg) {
        return new AjaxResult(500, msg);
    }

    /**
     * 失败
     */
    public static AjaxResult success() {
        return new AjaxResult(200, "成功");
    }


    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getResult() {
        return result;
    }

    public void setResult(Object result) {
        this.result = result;
    }
}
